1. Field of the Invention
The present invention relates to a program execution device capable of migrating, at a plurality of computers (hereinafter, suitably referred to as a program execution device) connected over a network, a process being executed to other computer while preserving its execution state and a process migrating method thereof, and a storage medium which stores a process migration control program.
2. Description of the Related Art
Set up of a distributed system which conducts processing extending over a plurality of computers connected over a network is conventionally realized by generating a software module for each individual computer and conducting communication between computers in the form of communication between software modules. Programmers therefore need to design and form a communication mechanism between modules in addition to processing of the system itself, which makes system realization difficult.
Under these circumstances, proposed as a technique of setting up such a distributed system with ease is a process migration technique by which a process being executed goes from one computer to another to enable one program and one module to realize processing on a plurality of computers. As a conventional technique of this kind, Telescript disclosed in Japanese Patent Laying-Open No. 7-182174, for example, enables process-migration of an object and a thread which is a program execution state among computers on a basis of a unit called agent. Then, describing an instruction xe2x80x9cgoxe2x80x9d in the program enables process migration at a time when the instruction xe2x80x9cgoxe2x80x9d is called.
Programs are all described in dedicated languages independent of hardware and run on an interpreter called engine. Process migration is realized by transferring the program described in the dedicated language and its execution state on the interpreter to an interpreter on a migration destination computer and reproducing there the original process prior to the migration based on the transferred program and execution state. In the technique disclosed in the literature, an individual agent to be migrated is a single thread and a process with a plurality of threads can not be migrated.
Another technique of setting up a distributed system is migrating a thread stack from a predetermined processor to another processor in a system where a plurality of processors share a single address space. As a conventional technique of this kind, disclosed, for example, in Japanese Patent Laying-Open No. 9-146904 is a technique of migrating a thread operating on a predetermined processor onto a memory region peculiar to other processor only by modifying an offset of a memory address. The system disclosed in the literature only realizes migration of one thread stack within a single address space and not migration of an address space itself. The system does not allow simultaneous migration of a plurality of threads either.
In recent years, there are many cases where in computer operation, a program should be described in multi-thread such as a case where communication and window operation are conducted simultaneously and a case where a plurality of processing are executed in parallel to each other. Under these circumstances, demanded is a program language execution environment for easily developing software operating on a plurality of computers connected over a network. As mentioned above, conventional process migration techniques, however, fail to allow migration of such a multi-thread program itself, making description of a complicated migration program with parallelism difficult.
As described above, conventional process migration techniques for use in establishing a distributed system have shortcomings that an object to be migrated is a single thread and that all threads of a process operating in multi-thread can not be migrated in the lump.
In the technique disclosed in Japanese Patent Laying-Open No. 7-182174, an engine itself which is an execution environment operates in multi-thread, while an agent as a migration unit is a single thread only.
In the technique recited in Japanese Patent Laying-Open No. 9-146904, what operates on a distributed system is a multi-thread, while what is to be migrated is an individual thread. In addition, the technique fails to take migration of a multi-thread process including information on an address space into consideration.
In these conventional techniques, a trial of migration of a multi-thread process, for example, causes, while a thread giving a process migration instruction executes serialization of a process, rewriting of a state of the process by other thread to result in generation of a conflict in the serialized data, causes a thread stack or an object in a process to stop with a conflict included as a result of external and forcible suspension of other thread by the thread giving a process migration instruction etc., or causes a situation that because discrimination is impossible between a thread originally suspended and a thread suspended due to process migration, which thread is to be suspended at an migration destination is unknown, all resulting in preventing normal operation.
In addition, the above-described conventional process migration technique is premised on that a program code describing a process to be migrated is a single code which can be migrated at any time during execution. In other words, the technique recited in Japanese Patent Laying-open No. 7-182174, for example, runs a program (code) described in a language independent of a computer on an interpreter. The technique recited in Japanese Patent Laying-Open No. 9-146904 operates a code of a real processor or a code of a virtual processor on an interpreter.
Program code operating on an interpreter, however, has a shortcoming that its execution speed is slower than that of a native code of a real processor.
In addition, processing largely dependent on a computer or an operating system can not be described singly with an interpreter in some cases.
On the other hand, a native code of a real processor limits a target which can be process-migrated only to the same processor environment, so that it fails to realize extensive migration.
Also, an interpreter allows various checks at execution as security, while a native code hardly enables such a security check.
An object of the present invention is to provide a program execution device which realizes process migration of a process operating in multi-thread to facilitate, when a complicated system which executes parallel execution of programs and a system where a program code dependent on a computer and a program code independent of a computer exist together are to be operated under distributed environments, set-up of such distributed systems with ease, and a process migrating method thereof, and a storage medium which stores a process migration control program.
According to the first aspect of the invention, a program execution device connected to other computer over a network and capable of migrating a process in execution to the other computer while preserving an execution state, comprises
a flag indicative of an execution state of a process which is provided for each process,
a table indicative of a state of each thread,
thread management means for setting values of the flag and the table according to an execution state of a thread, and
process management means for referring to the values of the flag and the table at the execution of a process migration instruction to set the flag to have a value indicating that migration is being executed only when process migration is enabled, as well as checking the flag at a thread in execution in the process and interrupting execution of the thread when the flag has the value indicating that process migration is in execution to execute processing for process migration.
In the preferred construction, the process management means executes the processing for process migration when all the threads in the process enter the stopped state.
In another preferred construction, the process management means distinguishes, in a program code to be executed, a computer-independent code to be executed on an interpreter independently of a computer and a computer-dependent code to be executed directly by a CPU dependently on a computer, and when a thread is executing the computer-dependent code, sets the thread at a migration-disabled state.
In another preferred construction, the thread management means preserves information regarding temporarily stopped states including suspend, sleep and synchronization waiting states on a thread stack, and restores the temporarily stopped state including the suspend, sleep or synchronization waiting state using the information regarding the temporarily stopped states on the thread stack received from other computer.
In another preferred construction, the thread management means preserves information regarding temporarily stopped states including suspend, sleep and synchronization waiting states on a thread stack, and
restores the temporarily stopped state including the suspend, sleep or synchronization waiting state using the information regarding the temporarily stopped states on the thread stack received from other computer, and
the process management means distinguishes, in a program code to be executed, a computer-independent code to be executed on an interpreter independently of a computer and a computer-dependent code to be executed directly by a CPU dependently on a computer, and when a thread is executing the computer-dependent code, sets the thread at a migration-disabled state.
In another preferred construction, the thread management means includes
state management means for operating the flag and the table, and
scheduling means for conducting scheduling of a thread and synchronization and exclusive control among threads,
the scheduling means being realized by a threading function of an operating system.
In another preferred construction, the process management means detects and discriminates codes embedded in a program code which declare migration-enabled and migration-disabled, and when a thread is executing the program code including a code declaring migration-disabled, sets the thread at the migration-disabled state.
According to the second aspect of the invention, a process migrating method of migrating, in a program execution device connected to other computer over a network, a process in execution to the other computer while preserving an execution state, comprising the steps of
at the execution of a process migration instruction, checking a state of a thread and only when process migration is enabled, setting a flag indicative of an execution state of a process which is provided for each process to have a value indicating that migration is being executed,
checking the flag at a thread in execution in the process,
when the flag has the value indicating that process migration is in execution, interrupting execution of the thread, and
when all the threads in the process enter the stopped state, executing processing for process migration.
In the preferred construction, at the flag setting step
a computer-independent code to be executed on an interpreter independently of a computer and a computer-dependent code to be executed directly by a CPU dependently on a computer are distinguished in a program code to be executed, and
when a thread is executing the computer-dependent code, determination is made that the thread is at a migration-disabled state.
In another preferred construction, at the thread execution interrupting step,
information regarding temporarily stopped states including suspend, sleep and synchronization waiting states is preserved on a thread stack.
In another preferred construction, at the flag setting step
a computer-independent code to be executed on an interpreter independently of a computer and a computer-dependent code to be executed directly by a CPU dependently on a computer are distinguished in a program code to be executed, and
when a thread is executing the computer-dependent code, determination is made that the thread is at a migration-disabled state, and
at the thread execution interrupting step,
information regarding temporarily stopped states including suspend, sleep and synchronization waiting states is preserved on a thread stack.
In another preferred construction, at the flag checking step, a value of the flag is periodically checked.
In another preferred construction, at the flag setting step,
codes embedded in a program code which declare migration-enabled and migration-disabled are detected and discriminated, and
when a thread is executing the program code including a code declaring migration-disabled, determination is made that the thread is at the migration-disabled state.
According to the third aspect of the invention, a computer readable memory which stores a process migration control program for controlling a program execution device connected to other computer over a network to migrate a process in execution to the other computer while preserving an execution state,
the process migration control program comprising the steps of
at the execution of a process migration instruction, checking a state of a thread and only when process migration is enabled, setting a flag indicative of an execution state of a process which is provided for each process to have a value indicating that migration is being executed,
checking the flag at a thread in execution in the process,
when the flag has the value indicating that process migration is in execution, interrupting execution of the thread, and
when all the threads in the process enter the stopped state, executing processing for process migration.
According to another aspect of the invention, a program execution device connected to other computer over a network and capable of migrating a process in execution to the other computer while preserving an execution state, comprises
a flag indicative of an execution state of a process which is provided for each process,
a table indicative of a state of each thread, thread management unit which sets values of the flag and the table according to an execution state of a thread, and
process management unit which refers to the values of the flag and the table at the execution of a process migration instruction to set the flag to have a value indicating that migration is being executed only when process migration is enabled, as well as checks the flag at a thread in execution in the process and interrupts execution of the thread when the flag has the value indicating that process migration is in execution to execute processing for process migration.
Other objects, features and advantages of the present invention will become clear from the detailed description given herebelow.